﻿@using GameSchool.HtmlHelpers
@model GameSchool.ViewModels.Exam.DetailsViewModel
@{
    ViewBag.Title = "Skrá nýtt próf fyrir " + +Model.currentCourse.Code + Model.currentCourse.Name + Model.currentCourse.Semester.Year + "-" + Model.currentCourse.Semester.SemesterOfYear;
}
<h2>
    Skrá nýtt próf fyrir @Model.currentCourse.Code, @Model.currentCourse.Name</h2>
<p>
    Notaðu formið hér að neðan til þess að skrá nýtt próf fyrir @Model.currentCourse.Code,
    @Model.currentCourse.Name á önninni @Model.currentCourse.Semester.Year-@Model.currentCourse.Semester.SemesterOfYear.
</p>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm(htmlAttributes: new { @class = "form-horizontal" }))
{
    @Html.ValidationSummary(true, "Ekki tókst að skrá nýtt próf. Vinsamlegast leiðréttu villurnar og reyndu aftur.")
    <div>
        <fieldset>
            <legend>Prófaupplýsingar</legend>
            <div class="control-group">
                @Html.LabelFor(m => m.exam.Name, new { @class = "control-label", style = "padding-top: 0px;" }, "Heiti")
                <div class="controls">
                    <p>@Model.exam.Name</p>
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.exam.Description, new { @class = "control-label", style = "padding-top: 0px;" }, "Lýsing")
                <div class="controls">
                    <p>@Model.exam.Description</p>
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.exam.HoursToFinish, new { @class = "control-label", style = "padding-top: 0px;" }, "Tími til að ljúka prófi")
                <div class="controls">
                    <p>@Model.exam.HoursToFinish klst</p>
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.exam.GradePercentage, new { @class = "control-label", style = "padding-top: 0px;" }, "Vægi í lokaeinkunn")
                <div class="controls">
                    <p>@Model.exam.GradePercentage%</p>
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.examHistory.Grade, new { @class = "control-label", style = "padding-top: 0px;" }, "Einkunn")
                <div class="controls">
                    <p>@string.Format("{0:0.0}", Model.examHistory.Grade)</p>
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.exam.ExamQuestions.Count, new { @class = "control-label", style = "padding-top: 0px;" }, "Fjöldi spurninga")
                <div class="controls">
                    <p>@Model.exam.ExamQuestions.Count</p>
                </div>
            </div>
            @Html.Hidden("ExamQuestionCounter", Model.exam.ExamQuestions.Count)
            @foreach (var q in Model.exam.ExamQuestions)
            {
                q.AnsweredId = Model.examHistory.ExamHistoryAnswers.First(i => i.ExamQuestionID == q.ExamQuestionNo).AnswerID;
                
                Html.RenderPartial("DetailsQuestionPartial", q);
            }
            <div class="form-actions">
                <a href="@Url.Action("List", new { id = Model.currentCourse.CourseID })" class="btn btn-success">
                    Til baka í prófalista</a>
            </div>
        </fieldset>
    </div>
}
<script type="text/javascript">
    $('.remove-question').live('click', function (event) {
        event.preventDefault();

        $(this).parents('div.question:first').remove();
    });

        
</script>
